with Ada.Text_Io; use Ada.Text_Io;
with Chaines.Controlees; use Chaines.Controlees;
with Ada.Unchecked_Deallocation;
package body Chaines.Controlees is

   procedure Free is new Ada.Unchecked_Deallocation(String,Ptr_String);

   procedure Initialize (C : in out Chaine_Controlee)is
   begin
      if (Trace) then
        Put_Line("Initialize");
      end if;

   end Initialize;

   procedure Adjust     (C : in out Chaine_Controlee) is
      S: String := C.Value.all;
   begin
      if (Trace) then
         Put_Line("Adjust");
      end if;
      C.Value := new String(1..S'Length);
      C.Value.all := s;
   end Adjust;

   procedure Finalize   (C : in out Chaine_Controlee) is
   begin
      if (C.Value /= null) then
         Free(C.Value);
      end if;
      if (Trace) then
         Put_Line("Finalize");
      end if;

   end Finalize;

   function Controler( S: String) return Chaine_Controlee is
      C: Chaine_Controlee;
   begin
      C.Value := new String(1..S'Length);
      C.Value.all := S;
      return C;
   end Controler;

   function Dechainer(C: Chaine_Controlee) return String is
   begin
      return C.Value.all;
   end Dechainer;

end Chaines.Controlees;
